<template>
  <div>
    <Form :model="form" ref="form" :rules="rules1" label-colon>
      <Card style="padding-left:10px;padding-right:10px;">
        <div class="title">基本信息</div>
        <div>
          <Row>
            <i-col
              span="4"
              style="height:32px; line-height:32px; text-align:right; padding-right:10px;"
            >
              <span style="color:red;">*</span>
              <span>会议主题:</span>
            </i-col>
            <i-col span="18">
              <FormItem prop="theme">
                <Input v-model="form.theme" placeholder="请输入" clearable style="width:30%" />
              </FormItem>
            </i-col>
          </Row>
          <Row>
            <i-col
              span="4"
              style="height:32px; line-height:32px; text-align:right; padding-right:10px;"
            >会议内容概述:</i-col>
            <i-col span="18">
              <FormItem>
                <Input
                  type="textarea"
                  rows="3"
                  v-model="form.content"
                  placeholder="请输入"
                  style="width:80%"
                  clearable
                  class="textarea"
                />
              </FormItem>
            </i-col>
          </Row>
          <Row>
            <i-col
              span="4"
              style="height:32px; line-height:32px; text-align:right; padding-right:10px;"
            >
              <span style="color:red;">*</span>
              <span>会议管理机构:</span>
            </i-col>
            <i-col span="18">
              <FormItem label prop="meetingOrganization">
                <Cascader change-on-select :data="organizaitonList" v-model="form.meetingOrganization" style="width:30%" placeholder="会议管理机构" clearable></Cascader>
              </FormItem>
            </i-col>
          </Row>
          <Row>
            <i-col
              span="4"
              style="height:32px; line-height:32px; text-align:right; padding-right:10px;"
            >主讲人:</i-col>
            <i-col span="20">
              <FormItem>
                <Cascader
                  change-on-select
                  :data="cascaderData"
                  trigger="hover"
                  @on-change="casChange"
                  v-model="form.speaker"
                  style="width:30%"
                ></Cascader>
              </FormItem>
            </i-col>
          </Row>
          <Row>
            <i-col
              span="4"
              style="height:32px; line-height:32px; text-align:right; padding-right:10px;"
            >
              <span style="color:red;">*</span>
              <span>会议地点</span>
            </i-col>
            <i-col span="18">
              <FormItem prop="location">
                <Input v-model="form.location" placeholder="请输入" clearable style="width:60%" />
              </FormItem>
            </i-col>
          </Row>
          <Row>
            <i-col
              span="4"
              style="height:32px; line-height:32px; text-align:right; padding-right:10px;"
            >
              <span style="color:red;">*</span>
              <span>会议时间:</span>
            </i-col>
            <i-col span="6">
              <FormItem prop="meetDate">
                <DatePicker
                  v-model="form.meetDate"
                  type="date"
                  placeholder="会议日期"
                  :editable="false"
                  :options="options"
                  @on-change="dateChange"
                ></DatePicker>
              </FormItem>
            </i-col>
            <i-col span="4">
              <FormItem prop="meetStartTime">
                <TimePicker
                  v-model="form.meetStartTime"
                  format="HH:mm"
                  placeholder="开始时间"
                  :editable="false"
                  @on-change="timeChange1"
                  style="width:60%;"
                ></TimePicker>
              </FormItem>
            </i-col>
            <i-col span="2">
              <span>——</span>
            </i-col>
            <i-col span="4">
              <FormItem prop="meetEndTime">
                <TimePicker
                  v-model="form.meetEndTime"
                  format="HH:mm"
                  placeholder="结束时间"
                  :editable="false"
                  @on-change="timeChange2"
                  style="width:60%;"
                ></TimePicker>
              </FormItem>
            </i-col>
          </Row>
          <Row>
            <i-col
              span="4"
              style="height:32px; line-height:32px; text-align:right; padding-right:10px;"
            >邮件提醒:</i-col>
            <i-col span="18">
              <FormItem prop="emailTime">
                <DatePicker
                  v-model="form.meetDate"
                  type="date"
                  placeholder="邮件提醒日期"
                  style="margin-right:20px;width:20%"
                  disabled
                ></DatePicker>
                <Input v-model="form.emailTime" placeholder="请输入" style="width:7%" />
                <span>点</span>
              </FormItem>
            </i-col>
          </Row>
        </div>
        <Row gutter="50">
          <i-col span="12">
            <div class="title">会议人员选择</div>
            <Row class="organizaiton">
              <div class="organizaitonTitle">人员选择</div>
              <Form :model="meetForm" ref="meetForm" :rules="rules2">
                <Row gutter="40">
                  <i-col span="20">
                    <FormItem prop="organization">
                      <Cascader change-on-select :data="organizaitonList" v-model="meetForm.organization" placeholder="所属机构" clearable></Cascader>
                    </FormItem>
                  </i-col>
                  <i-col span="4">
                    <FormItem>
                      <Button type="primary" @click="selectNoAttendMeeting">查询</Button>
                    </FormItem>
                  </i-col>
                </Row>
              </Form>
            </Row>
            <div class="transferContent">
              <!-- 穿梭框加了一个职级选择，但这次不上 -->
              <!-- <Row gutter="10">
                <i-col span="8">
                <Select v-model="locationName" filterable @on-change="locationNameChange()">
                  <Option v-for="item in locationNameList" :value="item.name" :key="item.name">{{ item.name }}</Option>
                </Select>
                <div style="height:177px;overflow:auto;border:1px solid #ccc;padding:3px;">
                  <div v-for="(item, index) in dataPeople" :key="index">
                    <div>
                      <span :class="item.showChild===true ? 'rot' : ''" style="padding-right:5px;">
                        <Icon type="ios-arrow-forward" @click="changeShowState(index)" />
                      </span>
                      {{item.name}}
                    </div>
                    <div v-if="item.showChild">
                      <div style="margin-left:20px;" v-for="(inner,ind) in item.children" :key="'inner'+inner.name" @click="getDetail(inner.name,index,ind)"><span :class="((fatherInd==index&&childInd==ind) || locationName == inner.name) ? 'highlight' : ''">{{inner.name}}</span></div>

                    </div>
                
                  </div>
                </div>
                </i-col>
                <i-col span="16">
                  <Transfer
                    :data="transferData"
                    :target-keys="targetKeys"
                    :render-format="renderFormat"
                    :titles="transferTitle"
                    @on-change="handleChange"
                  ></Transfer>
                </i-col>
              </Row>  -->
              <Transfer
                :data="transferData"
                :target-keys="targetKeys"
                :render-format="renderFormat"
                :titles="transferTitle"
                @on-change="handleChange"
              ></Transfer>
            </div>
            <div class="personFoot">
              <Button type="primary" @click="handleSubmit" :loading="saveLoaging">保存</Button>
            </div>
          </i-col>
          <i-col span="12">
            <div class="title">相关文件</div>
            <List border class="fileList">
              <div slot="header" class="fileContent">
                <span>文件名称</span>
                <span class="headerOperate">操作</span>
              </div>
              <ListItem v-for="item in fileCopy" :key="item">
                <ListItemMeta>
                  <span slot="description" style="color:#000">{{item.name}}</span>
                </ListItemMeta>
                <template slot="action">
                  <li>
                    <span @click="delectFile(item.id)" style="color:rgba(24, 144, 255, 1);">删除</span>
                  </li>
                </template>
              </ListItem>
            </List>
            <div class="fileFoot">
              <Uploadv
                ref="upload"
                :format="['pdf','mp4']"
                :on-format-error="handleFormatError"
                :before-upload="handleUpload"
                :show-upload-list="false"
                :on-success="uploadSuccess"
                :on-error="uploadFail"
                :headers="{
                  'Authorization':authorization,
                }"
                name="multipartFile"
                :data="{                  
                  meetSerialNo:meetingId
                }"
                :action="action"
                style="dispaly:inline-block"
              >
                <Button type="primary" style="margin-right:20px;">上传</Button>
              </Uploadv>
              <Page :total="total" @on-change="pageChange" :page-size="pageSize" transfer></Page>
            </div>
            <Button @click="cancel">取消</Button>
          </i-col>
        </Row>
      </Card>
    </Form>
    <Button @click="info" v-if="false"></Button>
  </div>
</template>

<script>
export default {
  data() {
    // 会议日期
    const validateTime1 = (rule, value, callback) => {
      if (value) {
      } else {
        callback(new Error("会议日期不能为空"));
      }
      callback();
    };
    // 会议开始时间
    const validateTime2 = (rule, value, callback) => {
      if (value) {
        let today = new Date();
        let yy = today.getFullYear();
        let mm = today.getMonth() + 1;
        if (mm < 10) {
          mm = "0" + mm;
        }
        let dd = today.getDate();
        if (dd < 10) {
          dd = "0" + dd;
        }

        let currentDay = yy + "-" + mm + "-" + dd;
        let h = today.getHours();
        if(h < 10){
          h = '0' + h;
        }
        let currentTime = h + ":" + today.getMinutes();

        // 如果是当天的会议
        if (this.form.meetDate.toLocaleString().substr(0, 10) === currentDay) {
          if (this.form.meetStartTime.toLocaleString().substr(0,2) == currentTime.toLocaleString().substr(0,2)) {
            if(this.form.meetStartTime.toLocaleString().substr(2,4) <= currentTime.toLocaleString().substr(2,4)){
              callback(new Error("会议开始时间不能早于当前时间"));
            }
          }else if(this.form.meetStartTime.toLocaleString().substr(0,2) < currentTime.toLocaleString().substr(0,2)) {
            callback(new Error("会议开始时间不能早于当前时间"));
          }
        }
      } else {
        callback(new Error("会议开始时间不能为空"));
      }
      callback();
    };
    // 会议结束时间
    const validateTime3 = (rule, value, callback) => {
      if (value) {
        if (value <= this.form.meetStartTime) {
          callback(new Error("会议结束时间不能小于会议开始时间"));
        }
      } else {
        callback(new Error("会议结束时间不能为空"));
      }
      callback();
    };
    // 邮件提醒时间
    const validateEmailTime = (rule, value, callback) => {
      if (value) {
        let reg = /^[0-9]{0,2}$/;
        if (value && (value < 0 || value > 24 || !reg.test(value))) {
          callback(new Error("时间为24小时制"));
        }
        let today = new Date();
        let yy = today.getFullYear();
        let mm = today.getMonth() + 1;
        if (mm < 10) {
          mm = "0" + mm;
        }
        let dd = today.getDate();
        if (dd < 10) {
          dd = "0" + dd;
        }
        let currentDay = yy + "-" + mm + "-" + dd;
        let currentTime = today.getHours() + ":" + today.getMinutes();
        // console.log(this.form.meetDate.toLocaleString().substr(0, 10) == currentDay)
        // 当天的会议----发送邮件时间不能早于当前时间
        if (this.form.meetDate.toLocaleString().substr(0, 10) == currentDay) {
          if (this.form.emailTime <= today.getHours()) {
            if (today.getMinutes() > 0) {
              callback(new Error("发送邮件时间不能早于当前时间"));
            }
          }
        }
        // 邮件提醒时间不能晚于会议开始时间
        if (
          this.form.meetStartTime &&
          (this.form.emailTime.length === 1
            ? "0" + this.form.emailTime
            : this.form.emailTime) > this.form.meetStartTime.substr(0, 2)
        ) {
          callback(new Error("发送邮件时间不能晚于会议开始时间"));
        }
      }
      callback();
    };
    return {
      locationNameList:[
        {name:"续期协管员"},
        {name:"见习续期服务专员"},
        {name:"初级续期服务专员一级"},
        {name:"初级续期服务专员二级"},
        {name:"中级续期服务专员一级"},
        {name:"中级续期服务专员二级"},
        {name:"高级续期服务专员一级"},
        {name:"高级续期服务专员二级"},
        {name:"高级续期服务专员三级"},
        {name:"资深续期服务专员一级"},
        {name:"资深续期服务专员二级"},
        {name:"见习续收组主任"},
        {name:"初级续收组主任一级"},
        {name:"初级续收组主任二级"},
        {name:"中级续收组主任一级"},
        {name:"中级续收组主任二级"},
        {name:"高级续收组主任一级"},
        {name:"高级续收组主任二级"},
        {name:"续收部经理"},
        {name:"总公司内勤"},
        {name:"省公司内勤"},
        {name:"市公司内勤"},
      ],
      dataPeople:[
        {
          name:"续期协管员",
          showChild: false,
          children:[
            {name:"续期协管员"},
          ]
        },
        {
          showChild: false,
          name:"续期服务专员",
          children:[
            {name:"见习续期服务专员"},
            {name:"初级续期服务专员一级"},
            {name:"初级续期服务专员二级"},
            {name:"中级续期服务专员一级"},
            {name:"中级续期服务专员二级"},
            {name:"高级续期服务专员一级"},
            {name:"高级续期服务专员二级"},
            {name:"高级续期服务专员三级"},
            {name:"资深续期服务专员一级"},
            {name:"资深续期服务专员二级"},
          ]
        },
        {
          showChild: false,
          name:"续收外勤主任",
          children:[
            {name:"见习续收组主任"},
            {name:"初级续收组主任一级"},
            {name:"初级续收组主任二级"},
            {name:"中级续收组主任一级"},
            {name:"中级续收组主任二级"},
            {name:"高级续收组主任一级"},
            {name:"高级续收组主任二级"},
          ]
        },
        {
          showChild: false,
          name:"续收经理",
          children:[
            {name:"续收部经理"},
          ]
        },
        {
          showChild: false,
          name:"内勤",
          children:[
            {name:"总公司内勤"},
            {name:"省公司内勤"},
            {name:"市公司内勤"},
          ]
        },
      ],
      // 不可选日期
      options: {
        disabledDate(date) {
          return date && date.valueOf() < Date.now() - 86400000;
        }
      },
      // 表单信息
      form: {
        theme: "",
        content: "",
        location: "",
        meetingOrganization: "",
        speaker: "",
        meetDate: "",
        meetStartTime: "",
        meetEndTime: "",
        emailTime: ""
      },
      meetForm: {
        organization: ""
      },
      organizaitonList: [],
      // 校验
      rules1: {
        theme: [{ required: true, message: "会议主题不能为空" }],
        meetingOrganization: [
          { required: true, message: "会议管理机构不能为空" }
        ],
        location: [{ required: true, message: "会议地点不能为空" }],
        meetDate: [
          { required: true, message: "会议日期不能为空" },
          { validator: validateTime1, trigger: "blur" },
          { validator: validateTime1, trigger: "change" }
        ],
        meetStartTime: [
          { required: true, message: "会议开始时间不能为空" },
          { validator: validateTime2, trigger: "blur" },
          { validator: validateTime2, trigger: "change" }
        ],
        meetEndTime: [
          { required: true, message: "会议结束时间不能为空" },
          { validator: validateTime3, trigger: "blur" },
          { validator: validateTime3, trigger: "change" }
        ],
        emailTime: [
          { validator: validateEmailTime, trigger: "blur" },
          { validator: validateEmailTime, trigger: "change" }
        ]
      },
      rules2: {
        organization: [{ required: true, message: "所属机构不能为空" }]
      },
      // 级联数据
      cascaderData: [],
      // 穿梭框数据
      transferData: [],
      targetKeys: [],
      transferTitle: ["未添加成员", "已有成员"],
      // 分页数据
      total: 0,
      pageIndex: 1,
      pageSize: 6,
      fileList: [],
      fileCopy: [],
      file: [],
      deleteFiles: [],
      fileIndex: 0,
      authorization: "",
      action: "",
      // 会议Id
      meetingId: "",
      saveLoaging: false,
      // 操作人Id
      userCode: null,
      fatherInd: "",
      child: "",
      locationName: "",
    };
  },
  methods: {
    //选择人员输入
    locationName(){
      this.locationName
    },
    //选择二级人员
    getDetail(name,fatherInd,ind){
      this.fatherInd = fatherInd;
      this.childInd = ind;
      this.locationName = name
      this.dataPeople.splice(1000,0)
      this.$forceUpdate();
      //之后这边加查询操作
    },
    //人员展示下拉
    changeShowState(index){
      this.dataPeople[index].showChild = !this.dataPeople[index].showChild;
      this.$forceUpdate();
    },

    // 提示语
    info(tip) {
      this.$Message.info(tip);
    },

    dateChange(value) {
      this.form.meetDate = value;
    },
    // 会议时间改变
    timeChange1(value) {
      this.form.meetStartTime = value;
    },
    timeChange2(value) {
      this.form.meetEndTime = value;
    },

    // 查询该机构下没有参加会议的人员
    selectNoAttendMeeting() {
      this.$refs.meetForm.validate(valid => {
        // console.log(valid);
        if (valid) {
          let obj = {
            index: 1,
            agentcodeList: null,
            managecom: this.meetForm.organization[this.meetForm.organization.length-1], //续期管理机构
            meetSerialNo: this.meetingId, //会议ID
            pageSize: 500,
            type: 0
          };
          // console.log(obj)
          this.transferData = [];
          this.api.selectMeettingNum(obj).then(res => {
            if (res.code == 200 && res.data != null) {
              res.data.records.forEach((element, index) => {
                let cont = { key: "", label: "", id: "" };
                cont.key = element.agentcode;
                cont.label = element.agentname;
                cont.id = element.agentcode;

                this.transferData.push(cont);
              });
            }else{
              this.info("查询失败");
            }
          });
        }
      });
    },

    // 穿梭框方法
    renderFormat(item) {
      return item.label;
    },

    handleChange(newTargetKeys, direction, moveKeys) {
      console.log(newTargetKeys); // 右边穿梭框数据
      console.log(direction); // 穿梭方向
      console.log(moveKeys); // 移动的数据的key
      this.targetKeys = newTargetKeys;
    },

    // 保存
    handleSubmit() {
      this.$refs.form.validate(valid => {
        // console.log(valid);
        if (valid) {
          if (this.targetKeys.length > 0) {
            this.saveLoaging = true;
            let obj = {
              UML: this.form.content, //会议内容概述
              createOperater: this.userCode, //操作人
              manageCom: this.form.meetingOrganization[this.form.meetingOrganization.length-1], //续期管理机构
              meetSerialNo: this.meetingId, //会议编码
              place: this.form.location, //地点
              speaker: this.form.speaker, //主讲人
              meettingDate: this.form.meetDate, //开始日期
              startTime: this.form.meetStartTime, //开始时间
              endTime: this.form.meetEndTime, //结束时间
              theme: this.form.theme, //会议主题
              warnDate: this.form.meetDate,
              warnMinute: this.form.emailTime //邮件提醒时长
            };
            console.log(obj);
            for (let item in obj) {
              if (obj[item] == null || obj[item].length == 0) {
                delete obj[item];
              }
            }
            

            // 删除文件
            if (this.deleteFiles) {
              this.deleteFiles.forEach(element => {
                if (element.id) {
                  let obj = {
                    id: element.id
                  };
                  this.api.deleteAttachment(obj).then(res => {
                    if (res.code == 200) {
                    } else {
                      this.$Message.info(res.msg);
                      return false;
                    }
                  });
                }
              });
            }

            // 操作
            this.api.createMeetting(obj).then(res => {
              if (res.code == 200) {
                this.participantSave();
                  //2020-12-15 用于触发弹窗
                  // this.api.sendNotice({
                  //   agentcode:this.targetKeys + "",
                  //   messageid:this.meetingId,
                  //   messagetype:1,
                  // }).then(res => {
                  //   console.log(res)
                  // })
              } else {
                this.saveLoaging = false;
                this.$Message.info(res.msg);
              }
            });
          } else {
            this.$Message.info("参会人员不能为空");
          }

          // this.$Message.info("信息填写成功");
        } else {
          this.$Message.info("信息填写有误");
        }
      });
    },

    // 保存人员选择
    participantSave() {
      this.api
        .participantSave({
          meetSerialNo: this.meetingId,
          userCodeList: this.targetKeys + ""
        })
        .then(res => {
          if (res.code == 200) {
            // this.$Message.info("人员选择成功");
            this.upload();
          } else {
            this.$Message.info("人员保存失败");
            this.upload();
          }
        });
    },

    // 上传文件
    handleFormatError() {
      this.$Message.info("只能上传pdf和mp4格式的文件！");
    },
    // 保存需要上传的文件
    handleUpload(file) {
      let hz = file.name.split(".");
      if (hz[1] == "pdf" || hz[1] == "mp4") {
        let keyID = Math.random()
          .toString()
          .substr(2);
        // 16位前端标志id
        file["keyID"] = keyID;
        this.file.push(file);
        // 显示文件列
        let f = {
          id: keyID,
          name: file.name
        };
        this.fileList.push(f);
        this.total = this.fileList.length;
        this.pageChange(1);
        return false;
      }
    },
    // 删除文件
    delectFile(keyID) {
      this.fileList.forEach((item, idx) => {
        if (item.id == keyID) {
          this.fileList.splice(idx, 1);
        }
      });
      this.total = this.fileList.length;
      this.pageChange(this.pageIndex);
      this.file = this.file.filter(item => {
        if (item.keyID == keyID) {
          // 保存到删除文件数组
          if (item.id) {
            this.deleteFiles.push(item);
          }
        }
        return item.keyID != keyID;
      });
    },

    // 上传文件
    upload() {
      // console.log(this.file);
      if (this.file.length > 0) {
        for (let i = 0; i < this.file.length; i++) {
          let item = this.file[i];
          // 重新提交原文件不上传
          if (item.id) {
            this.fileIndex++;
            // 如果全部是原文件
            if (this.fileIndex == this.file.length) {
              this.saveLoaging = false;
              this.sendEmail();
              this.file = [];
              this.$refs.form.resetFields();
              this.$router.push({
                // name: "mettingSet"
                path: "mettingSet"
              });
              this.$Message.info("会议制定提交成功！");
            }
          } else {
            this.$refs.upload.post(item);
          }
        }
      } else {
        this.saveLoaging = false;
        this.sendEmail();
        this.$refs.form.resetFields();
        this.file = [];
        this.$router.push({
                // name: "mettingSet"
                path: "mettingSet"
        });
        this.$Message.info("会议制定提交成功！");
      }
    },

    // 文件上传成功
    uploadSuccess(response, file, fileList) {
      // console.log(response, file, fileList)
      this.fileIndex++;
      this.$Message.info(file.name + "上传成功");
      if (this.fileIndex == this.file.length) {
        this.saveLoaging = false;
        this.sendEmail();
        this.file = [];
        this.$refs.form.resetFields();
        this.$router.push({
                // name: "mettingSet"
                path: "mettingSet"
        });
        this.$Message.info("会议制定提交成功!");
      }
      return true;
    },

    // 文件上传失败
    uploadFail(response, file, fileList) {
      // console.log(response, file, fileList);
      this.fileIndex++;
      this.$Message.info(fileList.name + "上传失败");
      if (this.fileIndex == this.file.length) {
        this.saveLoaging = false;
        this.file = [];
        this.$Message.info("会议制定提交失败！");
      }
      return false;
    },

    // 分页设置
    pageChange(pageIndex) {
      this.pageIndex = pageIndex;
      let temp = [];
      let i = (pageIndex - 1) * 6;
      temp = this.fileList.slice(i, i + 6);
      this.fileCopy = temp;
    },

    // 级联值改变
    casChange(value, selectedData) {
      console.log(value, selectedData);
      if (selectedData.length > 0) {
        this.form.speaker = selectedData[1].value;
      }

      // this.publishForm.casPeople = selectedData;
      // console.log(
      //   this.publishForm.casPeople[this.publishForm.casPeople.length - 1].key
      // );
    },

    // 取消按钮返回
    cancel() {
      this.$router.go(-1);
    },

    // 发送邮件 ---会议制定
    sendEmail() {
      this.api
        .sendEmail({ mailType: 0, meetSerialNo: this.meetingId })
        .then(res => {
          if (res.code == 200) {
          } else {
            this.info("发送邮件失败");
          }
        });
    },

    // 初始化
    initial() {
      // 续期机构下拉框
      this.api.remanagecomList().then(res => {
        if (res.code == 200 && res.data != null) {
          let arr = []
          arr.push(res.data)
          arr.forEach(one=>{
            one.value = one.comcode
            one.label = one.comcode + '-' + one.name
            one.children = one.chilDren || []
            if (one.children) {
              one.chilDren.forEach(two=>{
                two.value = two.comcode
                two.label = two.comcode + '-' + two.name
                two.children = two.chilDren || []
                if (two.children) {
                  two.children.forEach(three=>{
                    three.value = three.comcode
                    three.label = three.comcode + '-' + three.name
                    three.children = three.chilDren || []
                    if (three.children) {
                      three.children.forEach(four=>{
                        four.value = four.comcode
                        four.label = four.comcode + '-' + four.name
                        four.children = four.chilDren || []
                      })
                    }
                  })
                }
              })
            }
          })
          console.log(arr);
          this.organizaitonList = arr
        } else {
          this.organizaitonList = [];
        }
      });
      

      // 查询主讲人列表
      this.api.querySpeakers().then(res => {
        if (res.code == 200 && res.data != null) {
          res.data.forEach(element => {
            let cont = {
              value: "",
              label: "",
              children: []
            };
            if (element) {
              cont.value = element.manageCode;
              cont.label = element.manageComName;

              if (element.userinfo) {
                if (element.userinfo.length > 0) {
                  for (var i = 0; i < element.userinfo.length; i++) {
                    let temp = {
                      value: "",
                      label: ""
                    };
                    if (element.userinfo[i]) {
                      temp.value = element.userinfo[i].employeeNO;
                      temp.label = element.userinfo[i].name;

                      cont.children.push(temp);
                    }
                  }
                }
              }
              this.cascaderData.push(cont);
            }
          });
        }
      });
    }
  },
  mounted() {
    // 操作人code
    this.userCode = sessionStorage.getItem("useragentcode");
    // 文件上传地址
    this.action =
      // sessionStorage.getItem("userIp") + "api/meetting/meetingFileupload";
      "/scrm-gateway/scrm-uer/api/meetting/meetingFileupload";
    // token
    this.authorization = sessionStorage.getItem("credentials");
    this.initial();
    this.pageChange(1);
  },
  created() {
    this.meetingId = this.$route.query.meetingId;
    // console.log(this.meetingId);
  },
  beforeDestroy() {
    this.locationNameList = null;
    this.dataPeople = null;
    this.options = null;
    this.form = null;
    this.meetForm = null;
    this.organizaitonList = null;
    this.rules1 = null;
    this.rules2 = null;
    this.cascaderData = null;
    this.transferData = null;
    this.targetKeys = null;
    this.transferTitle = null;
    this.total = null;
    this.pageIndex = null;
    this.pageSize = null;
    this.fileList = null;
    this.fileCopy = null;
    this.file = null;
    this.deleteFiles = null;
    this.fileIndex = null;
    this.authorization = null;
    this.action = null;
    this.meetingId = null;
    this.saveLoaging = null;
    this.userCode = null;
    this.fatherInd = null;
    this.child = null;
    this.locationName = null;
  }
};
</script>

<style scoped lang="less">
@import "./index";
</style>

<style scoped>
.ivu-card{
  width: 100%;
}
.ivu-transfer-list{
  width:152px;
}
textarea {
  resize: none;
}
.ivu-upload-drag,
.ivu-upload-drag:hover {
  border: none;
}
.ivu-list-bordered .ivu-list-header {
  background-color: rgba(24, 144, 255, 0.04);
  padding: 0px;
}
.ivu-cascader-rel {
  width: auto;
}
.rot i{
  transform: rotate(90deg);
  transition-duration: 0.3s;
}
.highlight{
  background: #21a9f8;
}
</style>